package zhu.areas.team.action;

import java.util.Date;
import java.util.List;


import zhu.areas.team.data.Team;

import zhu.areas.team.service.ITeamXieService;



import com.opensymphony.xwork2.ActionSupport;


//团队管理中创建团队子模块
public class TeamXieAction extends ActionSupport {
	
	
	private static final long serialVersionUID = 1L;
	private int teamID;
	private int teamFounderID;
	private String teamName;
//	private String teamField;
	private String teamLevel;
	private Date regDate;
	private String teamSlogan;
//	private int teamAuState;
	private ITeamXieService teamXieService;
	
	private List<Team> teamlist;
 
	public String index(){	
		return SUCCESS;
	}
	
	private void convertToTeam(Team team) {		
		//team.setTeamID(teamID);
		team.setTeamFounderID(teamFounderID);
		team.setTeamName(teamName);
//		team.setTeamField(teamField);
		team.setTeamLevel(teamLevel);
		team.setRegDate(new Date());
		team.setTeamSlogan(teamSlogan);
//		team.setTeamAuState(1);
		}
	public void TeamToconvert(Team team) {
		
		this.teamID = team.getTeamID();
		this.teamName = team.getTeamName();
		this.teamFounderID = team.getTeamFounderID();
//		this.teamField = team.getTeamField();
		this.teamLevel = team.getTeamLevel();
		this.regDate = team.getRegDate();
		this.teamSlogan = team.getTeamSlogan();
	}
	
	public String addTeam(){         //添加团队
		Team team =new Team();
//		this.teamFounderID=(Integer) ServletActionContext.getRequest().getSession().getAttribute("userId");
//		System.out.println("团队创始人ID:"+this.teamFounderID); //获取当前登录用户ID
		this.convertToTeam(team);
		if (teamXieService.addTeam(team))
			return SUCCESS;
		return ERROR;
	}
	
	public String findteam(){        //查找审核团队找团队 
//		teamlist=teamXieService.findByTeamAuState(teamAuState);	
			
		return SUCCESS;		
	}
	
	public String deleteteam(){
		Team team =new Team();
        teamlist= teamXieService.findByTeamAuState(3);
        for(int i=0;i<teamlist.size();i++)
		{   team=teamlist.get(i);
        	teamXieService.deleteteam(team);
        	}
		return SUCCESS;
	}
	
	
	

	public int getTeamID() {
		return teamID;
	}

	public void setTeamID(int teamID) {
		this.teamID = teamID;
	}

	public int getTeamFounderID() {
		return teamFounderID;
	}

	public void setTeamFounderID(int teamFounderID) {
		this.teamFounderID = teamFounderID;
	}

	public String getTeamName() {
		return teamName;
	}

	public void setTeamName(String teamName) {
		this.teamName = teamName;
	}

//	public String getTeamField() {
//		return teamField;
//	}
//
//	public void setTeamField(String teamField) {
//		this.teamField = teamField;
//	}

	public String getTeamLevel() {
		return teamLevel;
	}

	public void setTeamLevel(String teamLevel) {
		this.teamLevel = teamLevel;
	}

	public Date getRegDate() {
		return regDate;
	}

	public void setRegDate(Date regDate) {
		this.regDate = regDate;
	}

	public String getTeamSlogan() {
		return teamSlogan;
	}

	public void setTeamSlogan(String teamSlogan) {
		this.teamSlogan = teamSlogan;
	}

//	public int getTeamAuState() {
//		return teamAuState;
//	}
//
//	public void setTeamAuState(int teamAuState) {
//		this.teamAuState = teamAuState;
//	}

	public ITeamXieService getTeamXieService() {
		return teamXieService;
	}

	public void setTeamXieService(ITeamXieService teamXieService) {
		this.teamXieService = teamXieService;
	}

	public List<Team> getTeamlist() {
		return teamlist;
	}

	public void setTeamlist(List<Team> teamlist) {
		this.teamlist = teamlist;
	}
	
	
	
}
